﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;
namespace IHISCETeim.Web.MachineSys.MacModel
{
    public partial class OC55NSLView : PageBase
    {
       
        protected override string DWZRef
        {
            get { return "OCompletingCheckList"; }
        }

        
        /// <summary>
        /// 需查看的机号
        /// </summary>
        protected string SerialNumber
        {
            get
            {
                return GetRequestValue<string>("SerialNumber");
            }
        }

        protected int Id
        {
            get
            {
                return GetRequestValue<int>("Id", 0);
            }
        }

        private OCompletingCheckInfo _obj;
        protected OCompletingCheckInfo obj
        {
            get
            {
                if (_obj == null)
                    _obj = OCompletingCheckController.GetById(Id);
                return _obj;
                //OMenuController.ge
            }
        }

        private  SerializableDictionary<string, bool> _QTJDJXMLDict = null;
        /// <summary>
        /// 启动前点检所有的项
        /// </summary>
        protected  SerializableDictionary<string, bool> QTJDJXMLDict
        {
            get
            {
                if (_QTJDJXMLDict == null)
                {
                    _QTJDJXMLDict = XmlSerializerHelper.Deserialize<SerializableDictionary<string, bool>>(obj.QDQDJItem);                    
                }
                return _QTJDJXMLDict;
            }
        }

        private SerializableDictionary<string, XRJCItem> _XRJCDict = null;
        /// <summary>
        /// 性能检查所有的项
        /// </summary>
        protected SerializableDictionary<string, XRJCItem> XRJCDict
        {
            get
            {
                if (_XRJCDict == null)
                {
                    try
                    {
                        _XRJCDict = XmlSerializerHelper.Deserialize<SerializableDictionary<string, XRJCItem>>(obj.XNJCItem);
                        // if (_XRJCDict.Count() <= 0)
                        // {
                        // _XRJCDict = new SerializableDictionary<string, XRJCItem>(CompleteCheckXMLHelper.XRJCDict);
                        //SerializableDictionary<string, float> tempdic = XmlSerializerHelper.Deserialize<SerializableDictionary<string, float>>(CompleteCheckXMLHelper.GetXRJCXMLStr());

                        foreach (var x in CompleteCheckXMLHelper.XRJCDict)
                        {
                            //XRJCItem tempitem = new XRJCItem();
                            //tempitem.Key = x.Key;
                            //tempitem.Value = x.Value.ToString();
                            //tempitem.NGValue = "OK";

                            if (!_XRJCDict.ContainsKey(x.Key))
                            {
                                XRJCItem tempitem = new XRJCItem();
                                tempitem.Key = x.Key;
                                tempitem.Value = "";
                                tempitem.NGValue = "OK";
                                _XRJCDict.Add(x.Key, tempitem);
                            }




                            //tempdic[x.Key] = HttpContext.Current.Request.GetRequestValue<float>(x.Key);
                        }
                        // }
                    }
                    catch
                    {
                        /**/

                    }
                }
                return _XRJCDict;
            }
        }


        private SerializableDictionary<string, bool> _GZQRDict = null;
        /// <summary>
        /// 工作确认所有的项
        /// </summary>
        protected SerializableDictionary<string, bool> GZQRDict
        {
            get
            {
                if (_GZQRDict == null)
                {
                    _GZQRDict = XmlSerializerHelper.Deserialize<SerializableDictionary<string, bool>>(obj.GZQRItem);
                    foreach (var x in CompleteCheckXMLHelper.GZQRDict)
                    {
                        if (!_GZQRDict.ContainsKey(x.Key))
                        {
                            _GZQRDict.Add(x.Key, true);
                        }
                    }
                }
                return _GZQRDict;
            }
        }

        /// <summary>
        /// 获取检查结果
        /// </summary>
        /// <param name="minx"></param>
        /// <param name="maxx"></param>
        /// <param name="itemname"></param>
        /// <returns></returns>
        protected string okOCInputBetween(float minx,float maxx,string itemname)
        {

            XRJCItem v = XRJCDict[itemname];
            if (Convert.ToSingle( v.Value) >= minx && Convert.ToSingle(v) <= maxx)
                return "OK";
            else
                return "<span style='color:red;'>NG</span>";
        }

    
        protected void Page_Load(object sender, EventArgs e)
        {
            this.rpDJNGItem.DataSource = OInspectionController.GetNGItemList(Id, "完成检查书");
            this.rpDJNGItem.DataBind();

            this.AddLog(Permission.查看, obj);
        }
    }
}